package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TDrive;
import com.hopu.blb_erp.mapper.DriverMapper;
import com.hopu.blb_erp.service.DriveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DriveServiceImpl extends ServiceImpl<DriverMapper, TDrive> implements DriveService {
    @Autowired
    private DriverMapper driverMapper;
    @Override
    public List<TDrive> findAllDrive() {
        return driverMapper.selectAllDrive();
    }
    //
    @Override
    public PageEntity<TDrive> findDriverPages(Integer current, Integer pageSize,String driverName,String driverLicense) {
        // 查询角色总数
        Integer count = driverMapper.selectCount(driverName,driverLicense);
        // 分页查询订单
        List<TDrive> drives = driverMapper.selectDriverPages((current-1) * pageSize, pageSize,driverName,driverLicense);
        // 包装到分页对象
        PageEntity<TDrive> page = new PageEntity<>();
        page.setCount(count);
        page.setData(drives);
        page.setCurrent(current);
        return page;
    }

}
